package com.example.it.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.it.R;
import com.example.it.bean.DataBean;
import com.example.it.bean.ItInfoItemBean;

import java.util.List;

public class ItInAdapter extends RecyclerView.Adapter<ItInAdapter.ViewHolder> {
    private Context context;
    private List<ItInfoItemBean.DataBean.DatasBean> datas;

    public ItInAdapter(Context context, List<ItInfoItemBean.DataBean.DatasBean> datas) {
        this.context = context;
        this.datas = datas;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(context).inflate(R.layout.item, parent, false);
        return new ViewHolder(inflate);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        ItInfoItemBean.DataBean.DatasBean datasBean = datas.get(position);
        holder.tilte.setText(datasBean.getTitle());
        holder.name.setText(datasBean.getChapterName());
        holder.rq.setText(datasBean.getNiceDate());
        holder.name1.setText(datasBean.getSuperChapterName()+datasBean.getAuthor());
    }

    @Override
    public int getItemCount() {
        return datas.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        TextView name;
        TextView rq;
        TextView tilte;
        TextView name1;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            name=itemView.findViewById(R.id.name);
            rq=itemView.findViewById(R.id.rq);
            tilte=itemView.findViewById(R.id.title);
            name1=itemView.findViewById(R.id.name1);
        }
    }
}
